var express = require("express");
var fs = require("fs");
var app = express();

app.use(haha);

app.listen(3000,"127.0.0.1");

function haha(req, res, next) {
    var filePath = req.originalUrl;
    console.log(filePath);
    // fs.readFile("./public" + filePath,function (err, data) {
    //     if(err){
    //         next();
    //     }
    //     res.send(data.toString());
    // });

    fs.readFile("./public" + filePath, function (err, data) {
        //console.log(err);

        if(err) {
            next();
            return ;
        }

        //console.log(data.toString());
        res.send(data.toString());
    });
}
